package main

import (
	"github.com/redis/go-redis/v9"
	"wztest/gocelery2"
)

func main() {
	rdb := redis.NewClient(&redis.Options{
		Addr:     "localhost:6379",
		Password: "123456",
		DB:       0,
	})

	// initialize celery client
	cli, _ := gocelery2.NewCeleryClient(
		gocelery2.NewRedisBroker(rdb),
		&gocelery2.RedisCeleryBackend{rdb},
		5, // number of workers
	)

	// task
	add := func(a, b int) int {
		return a + b
	}

	// register task
	cli.Register("worker.add", add)

	// stop workers gracefully (blocking call)
	defer cli.StopWorker()
	// start workers (non-blocking call)
	cli.StartWorker()

	select {}
}
